import request from '@/utils/request'

/**
 * 获取频道
 * @returns Promise
 */
export const getChannelAPI = () => {
  return request({
    url: '/v1_0/user/channels'
  })
}


/**
 * 获取所有频道
 * @returns Promise
 */
export const getAllChannelsAPI = () => {
  return request({
    url:'/v1_0/channels'
  })
}

/**
 * 删除频道
 * @param {Number} target 频道id
 * @returns  Promise
 */
export const delMyChannelAPI = (target) => {
  return request({
    url: `/v1_0/user/channels/${target}`,
    method:'DELETE'
  })
}


/**
 * 
 * @param {Number} id 频道id
 * @param {Number} seq 频道索引值 
 * @returns Promise
 */
export const addMyChannel = (id, seq) => {
  return request({
    url: '/v1_0/user/channels',
    method: 'PATCH',
    data: {
      channels: [
        {
          id,
          seq
        }
      ]
    }
  })
}